home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / misc / emu / amiSPIMsrc.lha / Tests / tt.bare.s < prev    next >
Text File  |  1994-01-17  |  3KB  |  116 lines

  1. # SPIM S20 MIPS simulator.
  2. # A simple torture test for the bare SPIM simulator.
  3. # Copyright (C) 1990-1994 James Larus, larus@cs.wisc.edu.
  4. # ALL RIGHTS RESERVED.
  5. #
  6. # SPIM is distributed under the following conditions:
  7. #
  8. # You may make copies of SPIM for your own use and modify those copies.
  9. #
  10. # All copies of SPIM must retain my name and copyright notice.
  11. #
  12. # You may not sell SPIM or distributed SPIM in conjunction with a commerical
  13. # product or service without the expressed written consent of James Larus.
  14. #
  15. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16. # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  17. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18. # PURPOSE.
  19. #
  20.  
  21. # $Header: /home/primost/larus/Software/SPIM/Tests/RCS/tt.bare.s,v 1.12 1994/01/18 03:23:44 larus Exp larus $
  22.  
  23. # Define the exception handling code.  This must go first!
  24. # Duplicate of standard trap handler.
  25.  
  26.     .data
  27.     .globl __m1_
  28. __m1_:    .asciiz "  Exception "
  29.     .globl __m2_
  30. __m2_:    .asciiz " occurred\n"
  31.     .ktext 0x80000080
  32.     mfc0 $26 $13    # Cause
  33.     mfc0 $27 $14    # EPC
  34.     addiu $v0, $0, 4    # syscall 4 (print_str)
  35. #    la $a0 __m1_
  36.     lui $a0, 0x1000
  37.     syscall
  38.     addiu $v0, $0, 1    # syscall 1 (print_int)
  39.     addu $a0 $0 $26
  40.     syscall
  41.     addiu $v0, $0, 4    # syscall 4 (print_str)
  42. #    la $a0 __m2_
  43.     lui $a0, 0x1000
  44.     ori $a0, $a0, 0xd
  45.     syscall
  46.     mtc0 $0, $13        # Clear Cause register
  47.     rfe            # Return from exception handler
  48.     addiu $27 $27 4        # Return to next instruction
  49.     jr $27
  50.     add $0, $0, $0        # Nop
  51.  
  52. # Standard startup code.  Invoke the routine main with no arguments.
  53.  
  54.     .text
  55.     .globl __start
  56. __start: jal main
  57.     addu $0, $0, $0        # Nop
  58.     addiu $v0, $0, 10
  59.     syscall            # syscall 10 (exit)
  60.  
  61.  
  62.     .globl main
  63. main:
  64.     addu $20, $0, $31    # Save return PC
  65.  
  66. # Test delayed branches:
  67.  
  68.     addiu $2, $0, 0
  69.     beq $0 $0 l1
  70.     addiu $2, $0, 1        # Delayed instruction
  71. l1:    addiu $3, $0, 1
  72.     bne $2 $3 fail
  73.     addu $0, $0, $0        # Nop
  74.  
  75. # Test delayed loads:
  76.  
  77.     .data
  78.     .globl d
  79. d:    .word 101
  80.     .text
  81.     addiu $3, $0, 0
  82.     lui $4 0x1000
  83.     lw $3 0x18($4)        # address of d
  84.     addu $0, $0, $0        # Nop
  85.     addiu $2, $3, 0        # Delayed instruction
  86.     addiu $2, $0, 101
  87.     bne $2 $3 fail
  88.     addu $0, $0, $0        # Nop
  89.  
  90. # Done !!!
  91.     .data
  92.     .globl sm
  93. sm:    .asciiz "\nPassed all tests\n"
  94.     .text
  95.     addiu $v0, $0, 4    # syscall 4 (print_str)
  96. #    la $a0 sm
  97.     lui $a0, 0x1000
  98.     ori $a0, $a0, 0x01c
  99.     syscall
  100.     addu $31, $0 $20    # Return PC
  101.     jr $31            # Return from main
  102.     add $0, $0, $0        # Nop
  103.  
  104.  
  105.     .data
  106.     .globl fm
  107. fm:    .asciiz "Failed test\n"
  108.     .text
  109. fail:    addiu $v0, $0, 4    # syscall 4 (print_str)
  110. #    la $a0 fm
  111.     lui $a0, 0x1000
  112.     ori $a0, $a0, 0x2f
  113.     syscall
  114.     addiu $v0, $0, 10    # syscall 10 (exit)
  115.     syscall
  116.